package se.webbzon.boltzmann.editor.component;

import javax.swing.JList;
import javax.swing.ListModel;

@Deprecated public class NullableJList<T> extends JList<T> {
	
	// Auto generated serial version UID

	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1684101906539079664L;
	// Whatever null is selected or not
	private boolean nullSelected;

	/*============================================================
	Constructors
	============================================================*/

	/** Creates a new nullable list with a list model. **/
	public NullableJList(ListModel<T> model) {
		super(model);
		nullSelected = true;
	}

	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public int getSelectedIndex() {
		if (nullSelected)
			return 0;
		else
			return super.getSelectedIndex();
	}

	@Override public T getSelectedValue() {
		if (nullSelected)
			return null;
		else
			return super.getSelectedValue();
	}

	@Override public boolean isSelectedIndex(int index) {
		if (nullSelected && index == 0)
			return true;
		else
			return super.isSelectedIndex(index);
	}

	@Override
	public void setSelectedIndex(int index) {
		// TODO Auto-generated method stub
		super.setSelectedIndex(index);
	}

	@Override
	public void setSelectedValue(Object anObject, boolean shouldScroll) {
		// TODO Auto-generated method stub
		super.setSelectedValue(anObject, shouldScroll);
	}
}
